#include <iostream>
#include <math.h>


double distance(double lat1, double long1, double lat2, double long2);

using namespace std;

int main()
{
	double lat1,long1,lat2,long2;
	cout <<"Enter lat1:";
	cin >> lat1;
	cout<< "Enter long1:";
	cin >> long1;
	cout <<"Enter lat2:";
	cin >> lat2;
	cout << "Enter long2:";
	cin >> long2;

	cout << "The distance between the two is "<<distance(lat1,long1,lat2,long2)<<endl;

}

double distance(double lat1, double long1, double lat2, double long2)
{
	double dlat, dlong,a,c;
	double convert=M_PIl/180;
	double R=6371;			//assumes kilometers		

	dlat= lat1-lat2;
	dlong=long1-long2;

	//We first need to convert it to radians from degree
	dlat =dlat *convert;
	dlong=dlong*convert;

	//a=Math.Pow(Math.Sin(dlat/2),2) + Math.Cos(lat1) * Math.Cos(lat2) * Math.Pow(Math.Sin(dlong/2),2);
	//c=2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1-a));

	a=pow(sin(dlat/2),2) + cos(lat1) * cos(lat2) * pow(sin(dlong/2),2);
	c=2 * atan2(sqrt(a), sqrt(1-a));
	
	return (R*c);
}

double heading(double lat1, double long1, double lat2, double long2)
{




}


